/**
 * @author 太阳当空丶赵
 * @date 2022/12/1-14:39
 * @version 1.0.0
 * BaseResult
 */
const BaseResultCode = require("./BaseResultCode")

module.exports = class BaseResult {
    /*
    * 状态码
    * */
    code
    /*
    * 提示文字
    * */
    msg
    /*
    * 返回数据
    * */
    data
    /*
    * 返回时间
    * */
    time

    constructor(obj) {
        this.code = obj.code
        this.msg = obj.msg
        this.data = obj.data
        this.time = Date.now()
    }

    /*
    * 请求成功
    * */
    static success(data) {
        return new BaseResult({...BaseResultCode.SUCCESS,data})
    }
    /*
    * 请求失败
    * */
    static error(data) {
        return new BaseResult({...BaseResultCode.FAILED,data})
    }
    /*
    * 参数校验失败
    * */
    static validateFailed() {
        return new BaseResult({...BaseResultCode.VALIDATE_FAILED})
    }

    /*
    * 参数校验失败
    * */
    static userValidateFailed() {
        return new BaseResult({...BaseResultCode.USER_VALIDATE_FAILED})
    }

}

